import java.util.Scanner;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class UserInputLoop {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = "";

        // Define the date format
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年M月dd日 HH:mm:ss");

        // Start the infinite loop
        while (!"n".equals(input)) {
            // Get the current time and format it
            String currentTime = LocalDateTime.now().format(formatter);

            System.out.println(currentTime + "：循环操作中~~~ 按n退出循环");

            // Read the user input
            input = scanner.nextLine();
        }

        // Close the scanner
        scanner.close();

        System.out.println("循环已退出。");
    }
}